package cn.cdl.springboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.cdl.springboot.entity.User;
import cn.cdl.springboot.service.UserService;

/**
 * @author yf141
 */

@Controller
@RequestMapping("index")
public class IndexController{
	
	@Autowired
	UserService userService ;
	
	@RequestMapping("/getIndex")
	@ResponseBody
	public String getIndex(){
		
		return "hello world";
	}
	
	
	@RequestMapping("/toIndex")
	public String toIndex(Model model){
		model.addAttribute("message", "hello world");
		return "main" ;
	}
	
	@RequestMapping("/getUserList")
	public String getUserList(Model model){
		
		List<User> l = userService.getList();
		model.addAttribute("list", l);
		return "user/user_list";
	}
	
}